package actions.demo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;

/**
 * 表单验证。
 * @author Administrator
 *
 */
public class StrutsFormValidatorAction extends Action{
    /**
     * @param mapping action mapping
     * @param form action form
     * @param request http request
     * @param response http response
     * @return action forward
     * @throws Exception any exception
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        DynaValidatorForm strutsValidatorForm = (DynaValidatorForm) form;
        request.setAttribute("strutsValidatorForm", strutsValidatorForm);
        String validatorSuccess = getResources(request).getMessage("info.SuccessValidatorForm");
        request.setAttribute("info", validatorSuccess);
        return mapping.findForward("success");
    }
}
